package com.mdinfo.gw.door.web

import com.mdinfo.base.common.bean.CommonResult
import com.mdinfo.base.common.bean.DataGrid
import com.mdinfo.gw.door.param.*
import com.mdinfo.gw.door.service.IDoorService
import com.mdinfo.gw.door.vo.DoorCardListDoorVo
import com.mdinfo.gw.door.vo.DoorListByDoorAccessIdVo
import com.mdinfo.gw.door.vo.DoorListDoorContainChildrenVo
import com.mdinfo.gw.door.vo.DoorListQueryVo
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import javax.validation.Valid

/**
 * Created by Administrator on 2018/1/12.
 */
@RestController
@RequestMapping("/sys/door")
class DoorController(
        val doorService:IDoorService
) {

    @RequestMapping("/listQuery")
    fun listQuery(@Valid param:DoorListQueryParam)
            : CommonResult<DataGrid<DoorListQueryVo>> {
        return doorService.listQuery(param)
    }

    @RequestMapping("/add")
    fun add(@Valid param:DoorAddParam)
            :CommonResult<Void>{
        return doorService.add(param)
    }

    @RequestMapping("/modify")
    fun modify(@Valid param:DoorModifyParam)
            :CommonResult<Void>{
        return doorService.modify(param)
    }

    @RequestMapping("/toDel")
    fun toDel(@Valid param: DoorToDelParam)
            :CommonResult<Void>{
        return doorService.toDel(param)
    }

    @RequestMapping("/listAll")
    fun listAll():CommonResult<List<DoorCardListDoorVo>>{
        return doorService.listAll()
    }


    @RequestMapping("/toOpen")
    fun toOpen(@Valid param: DoorToOpenParam)
            :CommonResult<Void>{
        return doorService.toOpen(param)
    }

    @RequestMapping("/toClose")
    fun toClose(@Valid param: DoorToCloseParam)
            :CommonResult<Void>{
        return doorService.toClose(param)
    }

    @RequestMapping("/listByDoorAccessId")
    fun listByDoorAccessId(@Valid param: DoorListByDoorAccessIdParam)
            :CommonResult<DataGrid<DoorListByDoorAccessIdVo>>{
        return doorService.listByDoorAccessId(param)
    }

    @RequestMapping("/listDoorContainChildren")
    fun listDoorContainChildren()
            :CommonResult<List<DoorListDoorContainChildrenVo>>{
        return doorService.listDoorContainChildren()
    }
}